<?php
namespace Products;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
use Products\Model\Categories;
use Products\Model\CategoriesTable;
use Products\Model\Products;
use Products\Model\ProductsTable;
use Products\Model\Productsnew;
use Products\Model\ProductsnewTable;
use Products\Model\Offers;
use Products\Model\OffersTable;
use Products\Model\Buy;
use Products\Model\BuyTable;
use Products\Model\History;
use Products\Model\HistoryTable;
use Products\Model\CountryAndIndustry;
use Products\Model\CountryAndIndustryTable;
use Products\Model\Bid;
use Products\Model\BidTable;
use Products\Model\Industry;
use Products\Model\IndustryTable;
use Zend\ModuleManager\Feature;
use Zend\Loader;
use Zend\EventManager\EventInterface;
use Zend\Mvc\Router\RouteMatch;
use Zend\ModuleManager\ModuleManager;
use Zend\Stdlib\Hydrator\ClassMethods;

use Users\Model\Usernew;
use Users\Model\UsernewTable;

class Module implements 
	Feature\AutoloaderProviderInterface,
    Feature\ConfigProviderInterface,
    Feature\ServiceProviderInterface
{
    public function getAutoloaderConfig()
    {
        return array(
            'Zend\Loader\ClassMapAutoloader' => array(
                __DIR__ . '/autoload_classmap.php',
            ),
            'Zend\Loader\StandardAutoloader' => array(
                'namespaces' => array(
                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                ),
            ),
        );
    }
    public function getConfig()
    {
        return include __DIR__ . '/config/module.config.php';
    }    
    public function getServiceConfig()
    {
        return array(
			
            'factories' => array( 
				'Products\Model\CategoriesTable' =>  function($sm) {
                   $tableGateway = $sm->get('CategoriesTableGateway');
                   $table = new CategoriesTable($tableGateway);
                   return $table;
                },
                'CategoriesTableGateway' => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new Categories());
                    return new TableGateway('categories', $dbAdapter, null, $resultSetPrototype);
                },
				'Products\Model\ProductsnewTable' =>  function($sm) {
                   $tableGateway = $sm->get('ProductsnewTableGateway');
                   $table = new ProductsnewTable($tableGateway);
                   return $table;
                },
                'ProductsnewTableGateway' => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new Productsnew());
                    return new TableGateway('productsnew', $dbAdapter, null, $resultSetPrototype);
                },
				'Products\Model\ProductsTable' =>  function($sm) {
                   $tableGateway = $sm->get('ProductsTableGateway');
                   $table = new ProductsTable($tableGateway);
                   return $table;
                },
                'ProductsTableGateway' => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new Products());
                    return new TableGateway('products', $dbAdapter, null, $resultSetPrototype);
                },
				//usersnew table
				'Users\Model\UsernewTable' =>  function($sm) {
                   $tableGateway = $sm->get('UsernewTableGateway');
                   $table = new UsernewTable($tableGateway);
                   return $table;
                },
                'UsernewTableGateway' => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new Usernew());
                    return new TableGateway('users_new', $dbAdapter, null, $resultSetPrototype);
                },
				
				'Products\Model\OffersTable' =>  function($sm) {
                   $tableGateway = $sm->get('OffersTableGateway');
                   $table = new OffersTable($tableGateway);
                   return $table;
                },
                'OffersTableGateway' => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new Offers());
                    return new TableGateway('offers', $dbAdapter, null, $resultSetPrototype);
                },
				'Products\Model\BuyTable' =>  function($sm) {
                   $tableGateway = $sm->get('BuyTableGateway');
                   $table = new BuyTable($tableGateway);
                   return $table;
                },
                'BuyTableGateway' => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new Buy());
                    return new TableGateway('buys', $dbAdapter, null, $resultSetPrototype);
                },
				'Products\Model\BidTable' =>  function($sm) {
                   $tableGateway = $sm->get('BidTableGateway');
                   $table = new BidTable($tableGateway);
                   return $table;
                },
                'BidTableGateway' => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new Bid());
                    return new TableGateway('bid', $dbAdapter, null, $resultSetPrototype);
                },
				'Products\Model\IndustryTable' =>  function($sm) {
                   $tableGateway = $sm->get('IndustryTableGateway');
                   $table = new IndustryTable($tableGateway);
                   return $table;
                },
                'IndustryTableGateway' => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new Industry());
                    return new TableGateway('industry', $dbAdapter, null, $resultSetPrototype);
                },
				'Products\Model\HistoryTable' =>  function($sm) {
                   $tableGateway = $sm->get('HistoryTableGateway');
                   $table = new HistoryTable($tableGateway);
                   return $table;
                },
                'HistoryTableGateway' => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new History());
                    return new TableGateway('history', $dbAdapter, null, $resultSetPrototype);
                },'Products\Model\CountryAndIndustryTable' =>  function($sm) {
                   $tableGateway = $sm->get('CountryAndIndustryTableGateway');
                   $table = new CountryAndIndustryTable($tableGateway);
                   return $table;
                },
                'CountryAndIndustryTableGateway' => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new CountryAndIndustry());
                    return new TableGateway('country_and_industry', $dbAdapter, null, $resultSetPrototype);
                },
			),			
        );
    }
}